package com.example.myspringboot.controller;

import com.example.myspringboot.bean.User;
import com.example.myspringboot.dao.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.stereotype.Repository;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.SessionAttributes;

@SessionAttributes("msg")
@Controller
public class UserController {
    @Autowired
    private UserMapper userMapper;

    @RequestMapping("/login")
    public String checklogin(Model model, User user) {
        User user1 = userMapper.checklogin(user);
        if (user1 != null) {
            model.addAttribute("msg", "当前登录用户:" + user.getUsername());
            return "main.html";
        } else {
            return "fail.html";
        }
    }

    @RequestMapping("/tonext")
    public String next(Model model) {
        return "next.html";
    }


    @RequestMapping("/zx")
    public String zx(Model model) {
        model.addAttribute("msg", "请登录");
        return "next.html";//前端重构界面和springboot(vue)的不同这里必须要加上界面
    }
}
